﻿namespace 光标小游戏
{
    internal class Program
    {
        /// <summary>
        /// 光标小游戏  *自顶向下 逐步细化
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            //1.定义整型x y及坐标(0,0)
            int x = 0;
            int y = 0;
            ConsoleKey input;
            //设置背景颜色
            Console.BackgroundColor = ConsoleColor.Blue;
            do
            {
                //2.在坐标(x,y)处输出hello
                Console.Clear();
                Console.SetCursorPosition(x, y);
                Console.Write("hello");
                //3.接受用户输入
                input = Console.ReadKey(true).Key;
                //4.根据用户输入调整x y
                switch (input)
                {
                    case ConsoleKey.A:
                        if (x > 0)
                            x--;
                        break;
                    case ConsoleKey.S:
                        if (y > 0)
                            y--;
                        break;
                    case ConsoleKey.D:
                        if (x < 80)
                            x++;
                        break;
                    case ConsoleKey.W:
                        if (y < 80)
                            y++;
                        break;
                    default:
                        break;
                }
            //5.回到第二步
            } while (input!=ConsoleKey.Enter);
        }
    }
}